package org.devbg.academy.corejava.shop.db.daos;

import java.util.List;

import org.devbg.academy.corejava.shop.db.entities.Category;
import org.devbg.academy.corejava.shop.db.entities.Product;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

public class ProductDAO extends BaseDAO<Product> {
	public ProductDAO() {
		super(Product.class);
	}

	@SuppressWarnings("unchecked")
	public List<Product> findByCategory(Category category) {
		Criteria findByCategoryCriteria = this.createCriteria();
		findByCategoryCriteria.add(Restrictions.eq("Category", category));
		List<Product> result = findByCategoryCriteria.list();
		return result;
	}
}
